package com.example.onlytest;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Button;


public class jia extends MainActivity implements  View.OnClickListener{
    EditText etX;
    EditText etY;
    Button btn;
    TextView tvResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.jia);
        setViews();
    }
    public void setViews(){
        etX = (EditText)findViewById(R.id.edX);
        etY = (EditText)findViewById(R.id.edY);
        btn = (Button)findViewById(R.id.btn);
        tvResult = (TextView)findViewById(R.id.tvResult);
        btn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int x = Integer.parseInt(etX.getText().toString());
        int y = Integer.parseInt(etY.getText().toString());
        int z = x+y;
        tvResult.setText("获得结果:" + z);
    }


}
